﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;

namespace University.Workshop.DataAccess
{
    public static class Reports
    {
        const string conecctionString = "Data Source=.\\SQLEXPRESS; Initial Catalog=DataBaseHotel; Integrated Security=True";
        public static DataTable LoadClient()
        {
            using (SqlConnection conexion = new SqlConnection(conecctionString))
            {
                
                conexion.Open();
                string sentencia = "SELECT FullName, ClientId, Telephone, Email, OrganizatioN, Country FROM [Client]";
                SqlCommand cmd = conexion.CreateCommand();

                cmd.CommandText = sentencia;
                cmd.CommandType = CommandType.Text;
                SqlDataReader reader;
                reader = cmd.ExecuteReader();
                cmd.Dispose();

                DataTable data = new DataTable();
                data.Dispose();
                data.Locale = CultureInfo.InvariantCulture;
                data.Load(reader);
               
                return data;
            }
        }

        public static DataTable TakenRooms()
        {
            using (SqlConnection conexion = new SqlConnection(conecctionString))
            {

                conexion.Open();
                string sentencia = "SELECT * FROM TokenRooms";
                SqlCommand cmd = conexion.CreateCommand();

                cmd.CommandText = sentencia;
                cmd.CommandType = CommandType.Text;
                SqlDataReader reader;
                reader = cmd.ExecuteReader();
                cmd.Dispose();

                DataTable data = new DataTable();
                data.Dispose();
                data.Locale = CultureInfo.InvariantCulture;
                data.Load(reader);
                //conexion.Close();
                //conexion.Dispose();
                return data;
            }
        }

        public static DataTable Employees()
        {
            using (SqlConnection conexion = new SqlConnection(conecctionString))
            {
                conexion.Open();
                string sentencia = "SELECT [CI],[Name],[Surname],[WorkArea] FROM Employee";
                SqlCommand cmd = conexion.CreateCommand();

                cmd.CommandText = sentencia;
                cmd.CommandType = CommandType.Text;
                SqlDataReader reader;
                reader = cmd.ExecuteReader();
                cmd.Dispose();

                DataTable data = new DataTable();
                data.Dispose();
                data.Locale = CultureInfo.InvariantCulture;
                data.Load(reader);
                return data;
            }
        }
    }
}
